package com.github.McPlugin.command;

import com.github.McPlugin.vexview.MyGui;
import lk.vexview.api.VexViewAPI;
import org.bukkit.*;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class MissionCommand implements CommandExecutor
{
    @Override
    public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings)
    {
        //命令发送者是玩家
        if (commandSender instanceof Player)
        {
            //类型转换，得到离线玩家
            OfflinePlayer offlinePlayer = (OfflinePlayer) commandSender;
            //玩家在线
            if (offlinePlayer.isOnline())
            {
                Player player = offlinePlayer.getPlayer();

                if (player.hasPermission("mission"))
                {
                    //显示任务界面
                    VexViewAPI.openGui(player, MyGui.tasksGui(player));
                    player.sendMessage("成功打开任务界面");
                    return true;
                }
            }
            //玩家不在线
            else
                return false;

        }
        //命令发送者不是玩家
        else
            return false;

        return false;
    }
}

